package com.zhongfl.crm.model.boss;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.zhongfl.crm.enums.boss.*;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.format.annotation.DateTimeFormat;
import tech.heptagram.core.common.model.PageVo;

import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * OrderMemorandum 备忘录
 *
 * @author tiantian
 * @date 2018/6/11 23:06
 */
@Data
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
public class OrderMemorandum extends PageVo {
    /**
     * 自增ID
     */
    private Long id;

    /**
     * 客户订单号
     */
    private String customerOrderNo;

    /**
     * 订单号
     */
    private String orderNo;

    /**
     * 操作人姓名
     */
    private String staffName;

    /**
     * 员工标签
     */
    private String staffLabel;

    ///**
    // * 操作人描述
    // */
    //private String staffDesc;

    /**
     * 头像
     */
    private String avatarUrl;

    /**
     * 阶段或方式
     */
    private OrderMemorandumStageEnum stage;
    private String stageName;

    public String getStageName() {
        if (Objects.isNull(stage)) {
            return "";
        }
        return stage.getDesc();
    }

    /**
     * 订单跟进状态
     */
    private OrderStatus orderStatus;
    private String orderStatusName;

    public String getOrderStatusName() {
        if (Objects.isNull(orderStatus)) {
            return "";
        }
        return orderStatus.getValue();
    }

    /**
     * 操作内容
     */
    private String content;

    private List<String> contents;


    /**
     * 操作内容 REMARK:备注 COMMENT:评论 LOG:日志
     */
    private OrderMemorandumTypeEnum type;

    private String typeName;

    private String getTypeName(){
        if(Objects.isNull(type)){
            return "";
        }
        return  type.getDesc();
    }

    /**
     * 父ID 备注是评论的父级
     */
    private Long parentId;

    /**
     * 操作时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date operateTime;

    /**
     * 通知人staffcode字符串，逗号分割
     */
    private String atStaffs;

    /**
     * 通知消息发送状态
     */
    private OrderMemorandumAtNoticeSendStatusEnum atNoticeSendStatus;

    /**
     * 励销跟进记录ID
     */
    private Long lxRevisitLogId;

    /**
     * 励销跟进记录评论父ID
     */
    private Long lxRevisitLogParentId;

    /**
     * 励销订单ID
     */
    private Long lxLoggableId;

    /**
     * 励销订单类型
     */
    private String lxLoggableType;

    /**
     * 同步状态
     */
    private OrderMemorandumSyncStatusEnum syncStatus;

    private Integer retryTimes;

    /**
     * 是否发送消息提醒
     */
    private Boolean sendMessage;

    /*--------------前端用字段---------------*/
    /**
     * 操作人code
     */
    private String staffCode;

    /**
     * 图片列表
     */
    private List<String> imgList;

    /*-----------页面用字段-----------------*/
    /**
     * 评论记录
     */
    private List<OrderMemorandum> comments;

    /**
     * 评论数量
     */
    private Integer commentNum;

    private String operateTimeDateFormat;
    private String operateTimeTimeFormat;

    private String day;

    public String getDay() {
        if (Objects.isNull(this.operateTime)) {
            return StringUtils.EMPTY;
        }

        String day = DateFormatUtils.format(this.operateTime, "MM-dd");
        return day;
    }

    private String time;

    public String getTime() {
        if (Objects.isNull(this.operateTime)) {
            return StringUtils.EMPTY;
        }
        return DateFormatUtils.format(this.operateTime, "HH:mm");
    }

    /**
     * 页面用ID
     */
    private String inputId;

    /**
     * 页面用ID
     */
    private String divId;
    /**
     * 页面用ID
     */
    private String imgId;

    /*-------------------------*/
    /**
     * 逻辑删除 0未删除 1已删除
     */
    private Integer deleted;

    /**
     * 最后更新人
     */
    private String modifiedBy;

    /**
     * 最后更新时间
     */
    private Date modifiedTime;

    /**
     * 订单名称
     */
    private String name;
}
